package com.sgb.kjwl.view.ui.adapter.machine;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.lease.MachineListEntity3;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;
@Deprecated
public class MachineListAdapter extends BaseRecycleAdapter<MachineListEntity3> {

    private TextView tvArea;
    private TextView priceView;
    private TextView tvTime;
    private TextView tvIsSelf;

    public MachineListAdapter(Context context, List<MachineListEntity3> datas) {
        super(context, R.layout.item_machine_list, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final MachineListEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        tvArea = holder.getItem().findViewById(R.id.tv_area);
        priceView = holder.getItem().findViewById(R.id.price_view);
        tvTime = holder.getItem().findViewById(R.id.tv_time);
        tvIsSelf = holder.getItem().findViewById(R.id.tv_isSelf);
        tvArea.setText(entity.getCityName() + "" + entity.getAreaName());
        tvIsSelf.setVisibility("1".equals(entity.getIsSelf()) ? View.VISIBLE : View.INVISIBLE);
        if ("1".equals(entity.getNegotiable())) {
            priceView.setText("面议");
        } else {
            priceView.setText(entity.getPrice() + " " + entity.getPriceUnitName());
        }

        try {
            tvTime.setText(DateUtils.stampToDay(entity.getUpdateTime()));
        } catch (Exception e) {

        }
    }
}
